<template>
  <!--  登录表单-->
  <div class="login_container">
    <h1>汉风蜗牛管理系统</h1>
    <!--    登陆区域-->
    <!--    头像-->
    <div class="login_box">

      <div class="avatar_box">
        <img src="../assets/img/timg.gif">
      </div>
      <!--    表单-->
      <el-form :model="loginForm" :rules="loginRules" ref="loginForm" label-width="" class="login_Form">
        <!--        账号-->
        <el-form-item prop="username">
          <el-input v-model="loginForm.username" prefix-icon="el-icon-user-solid"></el-input>
        </el-form-item>
        <!--        密码-->
        <el-form-item prop="password">
          <el-input v-model="loginForm.password" prefix-icon="el-icon-unlock"></el-input>
        </el-form-item>
        <!--        手机验证码-->
        <el-form-item prop="verifyCode">
          <div class="verifyCode_box">
            <el-input v-model="loginForm.verifyCode" prefix-icon="el-icon-mobile" class="verifyCode"></el-input>

            <img src="../assets/img/msFXK1.gif" class="verify_img">
          </div>
        </el-form-item>
        <el-form-item class="login_btn">
          <el-button type="primary" @click="submitForm('loginForm')">登录</el-button>
          <el-button @click="resetForm('loginForm')">重置</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>
<script>
  export default {
    name: 'login',
    data() {
      return {
        loginForm: {
          username: '',
          password: '',
          verifyCode: ''

        },
        loginRules: {
          username: [{
              required: true,
              message: '请输入账号',
              trigger: 'blur'
            },
            {
              min: 8,
              max: 11,
              message: '长度在 8 到 11个字符',
              trigger: 'blur'
            }
          ],
          password: [{
              required: true,
              message: '请输入密码',
              trigger: 'blur'
            },
            {
              min: 8,
              max: 16,
              message: '长度在 8 到 16 个字符',
              trigger: 'blur'
            }
          ],
          verifyCode: [{
              required: true,
              message: '请输入验证码',
              trigger: 'blur'
            },

          ]

        }
      }
    },
    methods: {
      submitForm(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            this.$router.push("/main")
            alert('submit!')
          } else {
            console.log('error submit!!')
            return false
          }
        })
      },
      resetForm(formName) {
        this.$refs[formName].resetFields()
      }
    }
  }
</script>

<style lang="less" scoped>
  h1 {
    text-align: center;
    width: 300px;
    height: 200px;
    position: absolute;
    left: 50%;
    margin-left: -150px;
    background-image: -webkit-linear-gradient(left, blue, #66ffff 10%, #cc00ff 20%, #CC00CC 30%, #CCCCFF 40%, #00FFFF 50%, #CCCCFF 60%, #CC00CC 70%, #CC00FF 80%, #66FFFF 90%, blue 100%);
    -webkit-text-fill-color: transparent;
    /* 将字体设置成透明色 */
    -webkit-background-clip: text;
    /* 裁剪背景图，使文字作为裁剪区域向外裁剪 */
    -webkit-background-size: 200% 100%;
    -webkit-animation: masked-animation 4s linear infinite;

    @keyframes masked-animation {
      0% {
        background-position: 0 0;
      }

      100% {
        background-position: -100% 0;
      }
    }
  }

  .login_container {
    height: 100%;
    background-color: aquamarine;
  }

  .login_box {
    width: 450px;
    height: 380px;
    background-color: #FFFFFF;
    border-radius: 3px;
    position: absolute;
    left: 50%;
    top: 50%;
    transform: translate(-50%, -50%);

    .avatar_box {
      width: 130px;
      height: 130px;
      border: 1px solid #EEEEEE;
      border-radius: 50%;
      padding: 10px;
      box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
      margin: -65px auto;
      background-color: #FFFFFF;

      img {
        width: 100%;
        height: 100%;
        border-radius: 50%;
        background-color: #EEEEEE;
      }
    }

    .login_Form {
      position: absolute;
      bottom: 0px;
      width: 100%;
      padding: 0px 20px;
      box-sizing: border-box;

      .login_btn {
        display: flex;
        justify-content: center;
      }

      .verifyCode_box {
        display: flex;

        .verifyCode {
          width: 70%;
          justify-content: left;
        }
      }

      .verify_img {
        justify-content: flex-end;
        height: 45px;
        width: 30%;
      }
    }
  }
</style>
